package com.estar.integaration.Controller.OrangeController;

import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayDeque;
import java.util.Queue;

/**
 * Author: YJL
 * Date: 2022/3/27 21:25
 **/

@RequestMapping("/orange")
@RestController
public class OrangeMessageController {

  Queue<String> temperatureQuque = new ArrayDeque<>();

  @PostMapping("/tempa")
  public String sendTempa(@RequestBody JSONObject jsonObject ){
    String temparature = jsonObject.getString("tempe");
    temperatureQuque.add(temparature);
    if(temperatureQuque.size() > 100){
      temperatureQuque.poll();
    }
    return "20000";
  }
}
